import { carousel } from "../../server/api";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [
      {
        icon: "/icon/管理端/我的审批x160.png",
        title: "我的审批",
      },
      // {
      //   icon:'/icon/管理端/抄送我的x160.png',
      //   title:'抄送我的'
      // },
      {
        icon: "/icon/管理端/已归档x160.png",
        title: "已归档",
      },
    ],
    obj: [
      {
        icon: "/icon/管理端/发布活动x160.png",
        title: "发布活动",
      },
      {
        icon: "/icon/管理端/活动管理x160.png",
        title: "活动管理",
      },
    ],
    sys: [
      {
        icon: "/icon/积分x280.png",
        title: "积分规则",
      },
    ],
    address: "",
    username: "",
    jnheight: wx.getMenuButtonBoundingClientRect().height,
    msg: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getmsg();
    const data = wx.getStorageSync("userInfo");
    const addresslist = data.userAdreessName.split(",");
    const rolename = data.realname;
    this.setData({
      address:
        addresslist[3] == undefined
          ? addresslist[2]
          : addresslist[2] == undefined
          ? addresslist[1]
          : addresslist[3],
      username: rolename,
    });
  },
  //获取通知信息
  async getmsg() {

    const res = await carousel();
    if (res.code == 200) {
      this.setData({msg:res.result})
    }
  },
  //审核管理详情
  auditdetail(e) {
    const index = e.currentTarget.dataset.id;
    console.log(index, "index");
    if (index == 0) {
      wx.navigateTo({
        url: "../../subPackagesB/pages/myapproval/myapproval",
      });
    } else if (index == 1) {
      wx.navigateTo({
        url: "../../subPackagesB/pages/Archived/Archived",
      });
    }
  },
  //活动管理详情
  activitydetail(e) {
    const index = e.currentTarget.dataset.id;
    if (index == 0) {
      wx.navigateTo({
        url: "../../subPackagesB/pages/launch/launch",
      });
    } else {
      wx.navigateTo({
        url: "../../subPackagesB/pages/eventmag/eventmag",
      });
    }
  },
  //积分规则管理
  integral(e) {
    wx.navigateTo({
      url: "../../subPackagesB/pages/points/points",
    });
  },
    
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
